﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Globalization;

namespace Microsoft.Office.OneNote
{
    internal static class FrameworkExceptions
    {
        internal static Exception UnknownXmlElement(XName name)
        {
            return new OneNoteException(FormatUI(ErrorMessages.UnknownXmlElement, name));
        }

        internal static Exception UnknownXmlElementID(XElement element)
        {
            return new OneNoteException(FormatUI(ErrorMessages.UnknownXmlElementID, element.Name));
        }

        internal static Exception ObjectDirty(OneNoteHierarchyObject obj)
        {
            return new InvalidOperationException(FormatUI(ErrorMessages.ObjectIsDirty, obj));
        }

        internal static Exception ObjectInvalid()
        {
            return new InvalidOperationException(ErrorMessages.ObjectInvalid);
        }

        internal static Exception ObjectIsServerView()
        {
            return new InvalidOperationException(ErrorMessages.ObjectIsServerView);
        }

        internal static Exception CannotChangeHierarchy()
        {
            return new InvalidOperationException(ErrorMessages.CannotChangeHierarchy);
        }

        private static string FormatUI(string format, params object[] args)
        {
            return string.Format(CultureInfo.CurrentUICulture, format, args);
        }
    }
}
